<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>添加商品</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
	<div class="layui-form-item">
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">商品专区：</label>
			<div class="layui-input-inline">
				<select name="zoneId" id="zoneId"  lay-verify="required" lay-filter="zoneId" class="select" lay-verify="type">
					<option value="0">选择专区</option>
					<option value="11">零售专区</option>
					<option value="12">会员专区</option>
					<option value="13">兑换专区</option>
					<option value="14">活动专区</option>
					<option value="15">新品专区</option>
					<option value="16">精品专区</option>
					<option value="17">开店商品专区</option>
					<option value="18">开店保证金专区</option>
					<option value="19">拼团区</option>
				</select>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">商品分类：</label>
			<div class="layui-input-inline" style="width:90px;">
				<select name="cfId1" id="cfId1" lay-filter="cfId1" class="select" lay-verify="type">
				</select>
			</div>
			<div class="layui-input-inline" style="width:90px;">
				<select name="cfId2" id="cfId2" lay-filter="cfId2" class="select" lay-verify="type">
				</select>
			</div>
			<div class="layui-input-inline" style="width:90px;">
				<select name="cfId3" id="cfId3" lay-filter="cfId3" class="select" lay-verify="type">
				</select>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">商品系列：</label>
			<div class="layui-input-inline" style="width:90px;">
				<select name="seriesId" id="seriesId" lay-filter="seriesId" class="select" lay-verify="type">
				</select>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">是否上架：</label>
			<div class="layui-input-inline" style="width:190px;">
				<input type="checkbox" class="switch_checked" lay-filter="stateS" lay-skin="switch" lay-text="上架|下架" checked>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">商品标题：</label>
			<div class="layui-input-inline" style="width:504px;">
				<input type="text" name="title" id="title" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">商品名称：</label>
			<div class="layui-input-inline">
				<input type="text" name="name" id="name" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">商品简称：</label>
			<div class="layui-input-inline">
				<input type="text" name="nameSort" id="nameSort" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">商品描述：</label>
			<div class="layui-input-inline" style="width:1132px;">
				<input type="text" name="nameDesc" id="nameDesc" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">商品编号：</label>
			<div class="layui-input-inline">
				<input type="text" name="code" id="code" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">供 货 商：</label>
			<div class="layui-input-inline">
				<input type="text" name="supplier" id="supplier" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">联合运营：</label>
			<div class="layui-input-inline" style="width:190px;">
				<select name="scope" id="scope"  lay-verify="required" lay-filter="select1">
					<option selected="selected" value="0">全网销售</option>
					<option value="1">自有市场销售</option>
				</select>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">是否预售：</label>
			<div class="layui-input-inline" style="width:190px;">
				<input type="checkbox" class="switch_checked" lay-filter="bookingS" lay-skin="switch" lay-text="是|否">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">预售时间：</label>
			<div class="layui-input-inline">
				<input type="text" name="bookingTime" id="bookingTime" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">发货时间：</label>
			<div class="layui-input-inline">
				<input type="text" name="deliveryTime" id="deliveryTime" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">----：</label>
			<div class="layui-input-inline" style="width:540px;">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">商品主图：</label>
			<div class="layui-input-inline" style="width:504px;">
								<div class="layui-upload">
                                    <button type="button" class="layui-btn" id="btnPic">上传主图</button>
                                    <input type="hidden" class="proImg" id="pic" name="pic" value=""/>
                                    <div class="layui-upload-list  one-img">
                                        <img class="layui-upload-img" id="demoPic" width="100px" height="100px">
                                        <p id="demoTextPic"></p>
                                    </div>
                                </div>

			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">首页图片：</label>
			<div class="layui-input-inline" style="width:504px;">
				<div class="layui-upload">
					<button type="button" class="layui-btn" id="btnIPic">上传主图</button>
					<input type="hidden" class="proImg" id="ipic" name="ipic" value=""/>
					<div class="layui-upload-list  one-img">
						<img class="layui-upload-img" id="demoIPic" width="100px" height="100px">
						<p id="demoTextIPic"></p>
					</div>
				</div>

			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">商品组图：</label>
			<div class="layui-input-inline" style="width:504px;">
								<div class="layui-upload">
                                    <button type="button" class="layui-btn" id="btnPicList">上传组图</button>
                                    <input type="hidden" class="proImg" id="picList" name="picList" value=""/>
                                    <div class="layui-upload-list  one-img">
                                        <p id="demoPicList"></p>
                                    </div>
                                </div>

			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">商品详情：</label>
			<div class="layui-input-inline" style="width:504px;">
				<div class="layui-upload">
					<button type="button" class="layui-btn" id="btnPicdetails">上传详情</button>
					<input type="hidden" class="proImg" id="picdetails" name="picdetails" value=""/>
					<div class="layui-upload-list  one-img">
						<p id="demoPicdetails"></p>
					</div>
				</div>

			</div>
		</div>

		<div class="layui-inline">
				<label class="layui-form-label" style="width:70px;">规格名称：</label>
				<div class="layui-input-inline">
					<input type="text" name="name1" id="name1" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label" style="width:70px;">规格简称：</label>
				<div class="layui-input-inline">
					<input type="text" name="nameSort1" id="nameSort1" autocomplete="off" class="layui-input">
				</div>
			</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">包装规格：</label>
			<div class="layui-input-inline">
				<input type="text" name="packSpec" id="packSpec" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">规格单位：</label>
			<div class="layui-input-inline">
				<input type="text" name="goodsUnit" id="goodsUnit" autocomplete="off" class="layui-input">
			</div>
		</div>
			<div class="layui-inline">
				<label class="layui-form-label" style="width:70px;">规格编号：</label>
				<div class="layui-input-inline">
					<input type="text" name="code1" id="code1" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label" style="width:70px;">商品重量：</label>
				<div class="layui-input-inline">
					<input type="text" name="weight" id="weight" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label" style="width:70px;">是否上架：</label>
				<div class="layui-input-inline" style="width:190px;">
					<input type="checkbox" class="switch_checked" lay-filter="state1S" lay-skin="switch" lay-text="上架|下架" checked>
				</div>
			</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">库 存 数：</label>
			<div class="layui-input-inline">
				<input type="text" name="inventory" id="inventory" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">报 警 数：</label>
			<div class="layui-input-inline">
				<input type="text" name="alarm" id="alarm" autocomplete="off" class="layui-input">
			</div>
		</div>
			<div class="layui-inline">
				<label class="layui-form-label" style="width:70px;">个人限量：</label>
				<div class="layui-input-inline">
					<input type="text" name="ulimit" id="ulimit" autocomplete="off" class="layui-input" value="0">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label" style="width:70px;">商品限量：</label>
				<div class="layui-input-inline">
					<input type="text" name="sumlimit" id="sumlimit" autocomplete="off" class="layui-input" value="0">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label" style="width:70px;">供 货 价：</label>
				<div class="layui-input-inline">
					<input type="text" name="supplierprice" id="supplierprice" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-inline" style="display: none;">
				<label class="layui-form-label" style="width:70px;">店主自返：</label>
				<div class="layui-input-inline" style="width:190px;">
					<input type="checkbox" class="switch_checked" lay-filter="activitySelfS" lay-skin="switch" lay-text="是|否" checked>
				</div>
			</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">推荐ID：</label>
			<div class="layui-input-inline">
				<input type="text" name="shareIdNo" id="shareIdNo" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">运 营 商：</label>
			<div class="layui-input-inline">
				<input type="text" name="operator" id="operator" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:70px;">运 营 部：</label>
			<div class="layui-input-inline">
				<input type="text" name="operations" id="operations" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
				<label class="layui-form-label" style="width:70px;">规格主图：</label>
				<div class="layui-input-inline" style="width:1000px;">
					<div class="layui-upload">
						<button type="button" class="layui-btn" id="btnPic1">规格主图</button>
						<input type="hidden" class="proImg" id="pic1" name="pic1" value=""/>
						<div class="layui-upload-list  one-img">
							<img class="layui-upload-img" id="demoPic1" width="100px" height="100px">
							<p id="demoTextPic1"></p>
						</div>
					</div>

				</div>
			</div>
			<table class="layui-table">
				<thead>
				<tr>
					<th>商城价</th>
					<th>商品成本</th>
					<th>运营成本</th>
					<th>运营部</th>
					<th>运营商</th>
					<th>分享赠</th>
					<th>消费赠</th>
					<th>随机红包</th>
					<th>购物卷</th>
					<th>代金券</th>
					<th>一星</th>
				</tr>
				</thead>
				<tbody>
				<tr>
					<td><input class="product-price" id="price" type="text" name="price" value=""></td>
					<td><input class="product-price" id="cost" type="text" name="cost" value=""></td>
					<td><input class="product-price" id="operat" type="text" name="operat" value=""></td>
					<td><input class="product-price" id="operationsPrice" type="text" name="operationsPrice" value=""></td>
					<td><input class="product-price" id="operatorPrice" type="text" name="operatorPrice" value=""></td>
					<td><input class="product-price" id="share" type="text" name="share" value=""></td>
					<td><input class="product-price" id="consumption" type="text" name="consumption" value=""></td>
					<td><input class="product-price" id="redEnvelope" type="text" name="redEnvelope" value=""></td>
					<td><input class="product-price" id="coupon" type="text" name="coupon" value=""></td>
					<td><input class="product-price" id="vouchers" type="text" name="vouchers" value=""></td>
					<td><input class="product-price" id="owner1" type="text" name="owner1" value=""></td>
				</tr>
				<thead>
				<tr>
					<th>二星</th>
					<th>三星</th>
					<th>诚信</th>
					<th>芦荟屋</th>
					<th>合开价</th>
					<th>合开优惠价</th>
					<th>合开限量</th>
					<th>预售价</th>
					<th>预售限量</th>
					<th>最小利润</th>
				</tr>
				</thead>
				<tbody>
				<tr>
					<td><input class="product-price" id="owner2" type="text" name="owner2" value=""></td>
					<td><input class="product-price" id="owner3" type="text" name="owner3" value=""></td>
					<td><input class="product-price" id="owner4" type="text" name="owner4" value=""></td>
					<td><input class="product-price" id="aloeVeraShop" type="text" name="aloeVeraShop" value=""></td>
					<td><input class="product-price" id="CooperationPrice" type="text" name="CooperationPrice" value=""></td>
					<td><input class="product-price" id="PreferentialPrice" type="text" name="PreferentialPrice" value=""></td>
					<td><input class="product-price" id="PreferentialLimited" type="text" name="PreferentialLimited" value=""></td>
					<td><input class="product-price" id="bookingPrice" type="text" name="bookingPrice" value=""></td>
					<td><input class="product-price" id="bookingLimited" type="text" name="bookingLimited" value=""></td>
					<td id="min">0</td>
				</tr>
				</tbody>
				<thead>
				<tr>
					<th>返消费券</th>
					<th>返代金券</th>
					<th>商品推荐</th>
					<th>服务商</th>
					<th>服务中心</th>
					<th>区域总监</th>
					<th>开店补贴</th>
					<th>分享诚信值</th>
					<th>分享旅游值</th>
					<th>消费诚信值</th>
					<th>消费旅游值</th>
				</tr>
				</thead>
				<tbody>
				<tr>
					<td><input type="text" name="activityCommission" id="activityCommission" class="product-price"></td>
					<td><input type="text" name="ownerCommission" id="ownerCommission" class="product-price"></td>
					<td><input class="product-price" id="shareGoods" type="text" name="shareGoods" value=""></td>
					<td><input class="product-price" id="service" type="text" name="service" value=""></td>
					<td><input class="product-price" id="areaService" type="text" name="areaService" value=""></td>
					<td><input class="product-price" id="commission2" type="text" name="commission2" value=""></td>
					<td><input class="product-price" id="commission1" type="text" name="commission1" value=""></td>
					<td><input class="product-price" id="shareFaith" type="text" name="shareFaith" value=""></td>
					<td><input class="product-price" id="consumptionFaith" type="text" name="consumptionFaith" value=""></td>
					<td><input class="product-price" id="shareTourism" type="text" name="shareTourism" value=""></td>
					<td><input class="product-price" id="consumptionTourism" type="text" name="consumptionTourism" value=""></td>
				</tr>
				</tbody>
			</table>




		<input type="text" id="operatorId" value="0">
		A<input type="text" id="suppliernoid" value="0">
		<div class="layui-form-item layui-hide">
			<input type="text" id="cfname" value="">
			<input type="text" id="zonename" value="">
			<input type="text" id="state" value="1">
			<input type="text" id="booking" value="0">

			<input type="text" id="activitySelf" value="1">
			<input type="text" id="state1" value="1">

			<input type="text" id="shareId" value="0">

			<input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-back-submit" value="确认">
		</div>
  </div>
</div>
<style>
	.product-price {
		width: 70px;
		height: 25px;
		border: none;
		padding: 0px;
		margin: 0px;
	}
</style>
<script src="/layui/layui.js"></script>
<script src="/layui/jquery.min.js"></script>
<script>
	var form1;
    layui.config({
        base: '/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function() {
        var $ = layui.$
            , form = layui.form;

        var $ = layui.jquery
            , upload = layui.upload;

        form1 = form;

        form.on('switch(stateS)', function (data) {
            //开关是否开启，true或者false
            var checked = data.elem.checked;
            if (checked) {
                $("#state").val(1);
            }
            else {
                $("#state").val(0);
            }
        });

        form.on('switch(state1S)', function (data) {
            //开关是否开启，true或者false
            var checked = data.elem.checked;
            if (checked) {
                $("#state1").val(1);
            }
            else {
                $("#state1").val(0);
            }
        });

        form.on('switch(bookingS)', function (data) {
            //开关是否开启，true或者false
            var checked = data.elem.checked;
            if (checked) {
                $("#booking").val(1);
            }
            else {
                $("#booking").val(0);
            }
        });

        form.on('select(cfId1)', function (data) {
            var option2 = $("<option>").val(0).text("选择分类");
            $("#cfId3").html(option2);
            loadfy(data.value, 2);
        });

        form.on('select(cfId2)', function (data) {
            loadfy(data.value, 3);
        });

        form.on('select(cfId3)', function (data) {
            $("#cfname").val(data.elem[data.elem.selectedIndex].text);
            var zoneId = $("#zoneId").val();
            var top = "";
            switch (zoneId) {
                case "11":
                    top = "L";
                    break;
                case "12":
                    top = "T";
                    break;
                case "13":
                    top = "D";
                    break;
                case "14":
                    top = "H";
                    break;
                default :
                    break;
            }
            if ($("#code").val() == "") {
                $("#code").val(top + $("#cfId3").val());
            }
            from.render('select');
        });

        form.on('select(zoneId)', function (data) {
            $("#zonename").val(data.elem[data.elem.selectedIndex].text);
            from.render('select');
        });

    });

    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#bookingTime' //指定元素
            ,type: 'datetime'
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#deliveryTime' //指定元素
            ,type: 'datetime'
        });

    });

        layui.use('upload', function(){
            var $ = layui.jquery
                ,upload = layui.upload;

        //代表图上传
        var uploadInst = upload.render({
            elem: '#btnPic'
            ,url: '/UploadFile'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                // obj.preview(function(index, file, result){
                //     $('#demoPic').attr('src', result); //图片链接（base64）
                // });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                //上传成功
                if(res.code == 0){
                    $("#pic").val(res.fileName);
                    $('#demoPic').attr('src', res.fileName);
                    return layer.msg('上传成功');
                }
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoTextPic = $('#demoTextPic');
                demoTextPic.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoTextPic.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });

            //首页图上传
            var uploadInst = upload.render({
                elem: '#btnIPic'
                ,url: '/UploadFile'
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    // obj.preview(function(index, file, result){
                    //     $('#demoIPic').attr('src', result); //图片链接（base64）
                    // });
                }
                ,done: function(res){
                    //如果上传失败
                    if(res.code > 0){
                        return layer.msg('上传失败');
                    }
                    //上传成功
                    if(res.code == 0){
                        $("#ipic").val(res.fileName);
                        $('#demoIPic').attr('src', res.fileName);
                        return layer.msg('上传成功');
                    }
                }
                ,error: function(){
                    //演示失败状态，并实现重传
                    var demoTextPic = $('#demoTextIPic');
                    demoTextPic.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                    demoTextPic.find('.demo-reload').on('click', function(){
                        uploadInst.upload();
                    });
                }
            });


            //规格图上传
            var uploadInst = upload.render({
                elem: '#btnPic1'
                ,url: '/UploadFile'
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    // obj.preview(function(index, file, result){
                    //     $('#demoIPic').attr('src', result); //图片链接（base64）
                    // });
                }
                ,done: function(res){
                    //如果上传失败
                    if(res.code > 0){
                        return layer.msg('上传失败');
                    }
                    //上传成功
                    if(res.code == 0){
                        $("#pic1").val(res.fileName);
                        $('#demoPic1').attr('src', res.fileName);
                        return layer.msg('上传成功');
                    }
                }
                ,error: function(){
                    //演示失败状态，并实现重传
                    var demoTextPic = $('#demoTextPic1');
                    demoTextPic.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                    demoTextPic.find('.demo-reload').on('click', function(){
                        uploadInst.upload();
                    });
                }
            });

            var picListArray = new Array();

            //图片组上传
            upload.render({
                elem: '#btnPicList'
                ,url: '/UploadFile'
                ,multiple: true
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    // obj.preview(function(index, file, result){
                    //     $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
                    // });
                }
                ,done: function(res){
                    //alert(res.fileName);
                    //上传完毕
                    picListArray.push(res.fileName);
                    picListLoad();
                }
            });

            function picListLoad()
			{
                $("#picList").val("");
                $('#demoPicList').html("");
                var i=0;
                for (i=0;i<picListArray.length;i++)
                {
                    if(i==0)
                    {
                        $("#picList").val(picListArray[0]);
                    }
                    else
                    {
                        $("#picList").val($("#picList").val()+","+picListArray[i]);
                    }
                    $('#demoPicList').append('<img src="'+ picListArray[i] +'" alt="'+ picListArray[i] +'" width="100" height="100" class="layui-upload-img"><a class="layui-btn layui-btn-xs demo-reload'+i+'" data="'+i +'">删除</a>')
                    $('#demoPicList').find('.demo-reload'+i).on('click', function(){
                       var pivpath =$(this).attr("data");
                        picListArray.splice(pivpath,1);
                        picListLoad();
                    });
                }

			}

            var picListArray1 = new Array();
            //商品详情上传
            upload.render({
                elem: '#btnPicdetails'
                ,url: '/UploadFile'
                ,multiple: true
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    // obj.preview(function(index, file, result){
                    //     $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
                    // });
                }
                ,done: function(res){
                    //alert(res.fileName);
                    //上传完毕
                    picListArray1.push(res.fileName);
                    picListLoad1();
                }
            });

            function picListLoad1()
            {
                $("#picdetails").val("");
                $('#demoPicdetails').html("");
                var i=0;
                for (i=0;i<picListArray1.length;i++)
                {
                    if(i==0)
                    {
                        $("#picdetails").val(picListArray1[0]);
                    }
                    else
                    {
                        $("#picdetails").val($("#picdetails").val()+","+picListArray1[i]);
                    }
                    $('#demoPicdetails').append('<img src="'+ picListArray1[i] +'" alt="'+ picListArray1[i] +'" width="100" height="100" class="layui-upload-img"><a class="layui-btn layui-btn-xs demo-reloadX'+i+'" data="'+i +'">删除</a>')
                    $('#demoPicdetails').find('.demo-reloadX'+i).on('click', function(){
                        var pivpath =$(this).attr("data");
                        picListArray1.splice(pivpath,1);
                        picListLoad1();
                    });
                }

            }



    });

    $(function(){
        loadfy(2,1);
        loadSeries();
    });

    function loadSeries() {
        $.ajax({
            type: "POST",
            url: "/goodsjson",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(GetJsonDataS1(3)),
            dataType: "json",
            success: function (data) {
                if (data.code == "000000") {
                    var option1 = $("<option>").val(0).text("选择商品系列");
                    $("#seriesId").html(option1);
                    $.each(data.data, function (i, item) {
                        var option1 = $("<option>").val(item.id).text(item.name);
                        $("#seriesId").append(option1);
                    });

                    form1.render('select');
                }
                else {
                    alert(data.errorDetail);
                }
            },
            error: function (message) {
                alert("提交数据失败！"+message);
            }
        });
    }
    
    function loadfy(pid,m) {
        $.ajax({
            type: "POST",
            url: "/goodsjson",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(GetJsonDataS1(pid)),
            dataType: "json",
            success: function (data) {
                if (data.code == "000000") {
                    var option1 = $("<option>").val(0).text("选择分类");
                    $("#cfId"+m).html(option1);
                    $.each(data.data, function (i, item) {
                        var option1 = $("<option>").val(item.id).text(item.name);
                        $("#cfId"+m).append(option1);
                    });

                    form1.render('select');
                }
                else {
                    alert(data.errorDetail);
                }
            },
            error: function (message) {
                alert("提交数据失败！"+message);
            }
        });
    }

    function GetJsonDataS1(pid) {
        var json = {
            "url": "Classification/List",
            "parm":{"pid":pid,"state":1}
        };
        return json;
    }

    var operatorId=0;
    $("#operator").blur(function () {
        var urls="/user?url=User%2FgetUserAndNoInfo&userNo="+$("#operator").val();
        $.ajax({
            url: urls,
            type: "GET",
            async:false,
            dataType: "json", //指定服务器返回的数据类型
            success: function(result) {
                if(result.code=="000000"){
                    if(result.data!=null){
                        operatorId=result.data.id;
                        $("#operatorId").val(operatorId);
                    }else {
                        operatorId=-1;
                        alert("编号不存在!!");
                        $("#operator").val("");
                        $("#operatorId").val(0);
                    }
                }
            }
        });
    });

    var suppliernoId=0;
    $("#supplier").blur(function () {
        var urls="/user?url=User%2FgetUserAndNoInfo&userNo="+$("#supplier").val();
        $.ajax({
            url: urls,
            type: "GET",
            async:false,
            dataType: "json", //指定服务器返回的数据类型
            success: function(result) {
                if(result.code=="000000"){
                    if(result.data!=null){
                        suppliernoId=result.data.id;
                        $("#suppliernoid").val(suppliernoId);
                    }else {
                        operatorId=-1;
                        alert("编号不存在!!");
                        $("#supplier").val("");
                        $("#suppliernoId").val(0);
                    }
                }
            }
        });
    });

    var shareId=0;
    $("#shareIdNo").blur(function () {
        var urls="/user?url=User%2FgetUserAndNoInfo&userNo="+$("#shareIdNo").val();
        $.ajax({
            url: urls,
            type: "GET",
            async:false,
            dataType: "json", //指定服务器返回的数据类型
            success: function(result) {
                if(result.code=="000000"){
                    if(result.data!=null){
                        shareId=result.data.id;
                        $("#shareId").val(shareId);
                    }else{
                        shareId=0;
                        alert("编号不存在!!");
                        $("#shareIdNo").val("");
                        $("#shareId").val(0);
                    }
                }
            }
        });
    });
    
</script>
</body>
</html>